#include <iostream>
class Base
{
public:
    virtual void test()
    {
        std::cout << "Base class...";
    }
};

class Child : public Base
{
public:
    void test() final
    {
        std::cout << "Child class...";
    }
};

class GrandChild  : public Child
{
public:
    // 语法错误, 不允许重写
    void test()
    {
        cout << "GrandChild class...";
    }
};

class Child2 final: public Base
{
public:
    void test()
    {
        std::cout << "Child class...";
    }
};

// error, 语法错误
class GrandChild2 : public Child2
{
public:
};



/* 作者: 苏丙榅
链接: https://subingwen.cn/cpp/final/
来源: 爱编程的大丙
著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。 */